new Vue({
	el: '#law',
	data:{
		tableData: [], //所有案件
		Case_law: {
			caseId:'',
			clientId:{
				clientName:''
			},
			caseStatus:'',
			caseTypeid:{
				caseTypeid:''
			},
			closeState:''
		},
		case_type:[],  //所有类型
		type_key:{
			value:'caseTypeid',
			label:'typeName',
			children:'children'
		},
		selectcaseTypeid: [], //选择的类型 两个参数
		handleKey:'',//操作绑定的值
		dialogVisible: false, //是否打开单条案件模态框
		law:{			//模态框显示的案件详情信息
			caseId:'',
			clientId:{
				cname:'',
			},
			oppositeId:{
				cname:'',
			},
			locusStandi:'',
			causeOfAction:'',
			causeDetails:'',
			caseStatus:'',
			objectOfAction:'',
			caseTypeid:{
				typeName:''
			},
			recordFilename:'',
			submitId:{
				user_name:''
			},
			submitDate:'',
			mainLawyer:{
				empName:''
			},
			agencyMoney:'',
			blendMoney:'',
			amountMoney:'',
			courtId:{
				courtName:''
			},
			sessionDate:'',
			stateSessionDate:'',
			trialDate:'',
			closeState:'',
			closeMode:'',
			closeDate:'',
			closeDate:''
		},
		//案件详情加载动画，true开启，false关闭  
		law_loding:true
	},
	created(){
		this.initquery();
	},
	methods: {
		initquery(){
			const loading =this.$loading({
				lock: true,
				text: 'Loading',
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			});
			this.$http.post("http://localhost:8080/law/selectLikeList",
				{emulateJSON:true}).then(result=>{
				var msg = eval("("+result.body+")");
				this.tableData = msg.data;
			});
			this.$http.post("http://localhost:8080/case_type/queryAll",
				{emulateJSON:true}).then(result=>{
				var msg = eval("("+result.body+")");
				this.case_type = msg.data;
			});
			loading.close();
		},
		onSubmit() {
			//得到模糊查询选择的所有的值
			var typeid = this.selectcaseTypeid[1];
			if(typeid == undefined){
				typeid=-1
			}
			this.Case_law.caseTypeid.caseTypeid = typeid;
			var data = JSON.stringify(this.Case_law);
			this.$http.post("http://localhost:8080/law/selectLikeList",
				{"data":data},
				{emulateJSON:true}).then(result=>{
				var msg = eval("("+result.body+")");
				this.tableData = msg.data;
			});
		},
		handleSizeChange(val) {
			console.log(`每页 ${val} 条`);
		},
		handleCurrentChange(val) {
			console.log(`当前页: ${val}`);
		},
		handleClose(done) {
			this.$confirm('确认关闭？')
				.then(_ => {
					done();
				})
				.catch(_ => {});
		},
		handle(){
			alert(this.handleKey);
		},
		queryByid(caseid){ //跳转到这个案件的详细信息页面
			//打开模态框
			this.dialogVisible = true;
			//得到选择的案件id
			this.$http.post("http://localhost:8080/law/queryByid",
				{"caseid":caseid},
				{emulateJSON:true}).then(result=>{
				var msg = eval("("+result.body+")");
				this.law = msg.data;
			});
			//将加载动画关闭
			this.law_loding =false;
		},
		cost(caseid){ //费用减免申请
			//将案件id保存到本地
			localStorage.setItem("caseid",caseid);
			window.location.href="Cost_relief.html"
		},
		gathering(caseid){  //添加收款记录
			//将案件id保存到本地
			localStorage.setItem("caseid",caseid);
			window.location.href="Case_gathering.html"
		},
		invoice(caseid){  //跳转到发票申请页面
			window.location.href="../finance/daiopeninvoice.html"
		},
		closelaw(caseid){   //结案申请
			//跳转到结案页面
			localStorage.setItem("caseid",caseid);
			window.location.href="Case_closelaw.html";
		}
		
	}
})